using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;
using System.Web.Administration;
using Microsoft.Web.Administration;


namespace NutriLeaf.Services
{
    public class WebRole : RoleEntryPoint
    {
        public override bool OnStart()
        {
            // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config  
            DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
            diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();



        }

        //public override bool OnStart()
        //{
        //    // This only works in compute emulator.
        //    // on the cloud, you might delete this code or use siteName = "Web"
        //    var siteName = "NutriLeafProject.ServiceApplication";

        //    using (ServerManager serverManager = new ServerManager())
        //    {
        //        foreach (Site site in serverManager.Sites)
        //        {
        //            if (site.Name.Contains(siteName))
        //            {
        //                var appPoolName = site.Applications.First().ApplicationPoolName;
        //                var appPool = serverManager.ApplicationPools[appPoolName];
        //                appPool.ProcessModel.IdentityType = ProcessModelIdentityType.ApplicationPoolIdentity;
        //            }
        //        }
        //        serverManager.CommitChanges();
        //    }

        //    return base.OnStart();
        //}
    }
}
